home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr47 / wasm223.zip / JUSTIFY2.ASM < prev    next >
Assembly Source File  |  1993-05-04  |  1KB  |  47 lines

  1. ;**********************************;
  2. ; WASM String Left Justify         ;
  3. ; By Eric Tauck                    ;
  4. ;                                  ;
  5. ; Defines:                         ;
  6. ;                                  ;
  7. ;   StrJusL  left justify a string ;
  8. ;                                  ;
  9. ; Requires:                        ;
  10. ;                                  ;
  11. ;    STRING.ASM                    ;
  12. ;**********************************;
  13.  
  14.         jmps    _justify2_end
  15.  
  16. ;========================================
  17. ; Left justify a string.
  18. ;
  19. ; In: AX= string; CX= final length of
  20. ;     string; DL= pad character.
  21.  
  22. StrJusL PROC    NEAR
  23.         push    di
  24.  
  25.         push    cx
  26.         push    dx
  27.         mov     di, ax
  28.         call    StrLen          ;get length
  29.         pop     dx
  30.         pop     cx
  31.         sub     cx, ax          ;characters to pad
  32.         jbe     _stjul1         ;exit if no padding
  33.  
  34.         add     di, ax          ;point to last byte
  35.         mov     al, dl
  36.         cld
  37.         rep
  38.         stosb                   ;store padding
  39.         sub     al, al
  40.         stosb                   ;store new NUL
  41.  
  42. _stjul1 pop     di
  43.         ret
  44.         ENDP
  45.  
  46. _justify2_end
  47.